<template>
  <div class="tab-controll">
    <div class="tab-item" v-for="(item,index) in titles" :key="index" :class="{active:index === currentIndex}" @click="itemClick(index)">
      <span>{{item}}</span>
    </div>
  </div>
</template>

<script>
export default {
  name:'TabControll',
  props:{
    titles:{
      type:Array,
      default(){
        return []
      }
    }
  },
  data(){
    return{
      currentIndex:0
    }
  },
  methods:{
    itemClick(index){
      this.currentIndex = index;
    }
  }
}
</script>

<style scoped>
.tab-controll{
  display: flex;
  text-align: center;
  line-height: 40px;
  background: #fff;
  font-size: 16px;
}
.tab-item{
  flex:1;
}
.active{
  color:var(--color-tint);
}
.active span{
  border-bottom: 3px solid var(--color-tint);
  padding: 3px;
}
</style>